package gen.tools.query;

import gen.tools.Widgets;
import gen.tools.structures.Subsys4Maintain;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.gson.Gson;

public class QuerySubsys4Maintain extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public QuerySubsys4Maintain() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request,response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		final Widgets wid = new Widgets();
		request.setCharacterEncoding( wid.UIcodeSet );
		response.setCharacterEncoding( wid.UIcodeSet );
		response.setContentType("application/json");
		
		ArrayList<Subsys4Maintain> alOfS4M = new ArrayList<Subsys4Maintain>();
		
		try {
			alOfS4M = wid.getsubsys4maintain();	
		} catch( Exception e) {
			wid.errLog(e);
		}
		response.getWriter().write( new Gson().toJson(alOfS4M) );
		
	}
}
